1. Technical Field
This invention generally relates to query optimizers in a computer database system, and more specifically relates to improving a database query that searches for a character string in a computer database.
2. Background Art
Databases are computerized information storage and retrieval systems. A database system is structured to accept commands to store, retrieve and delete data using, for example, high-level query languages such as the Structured Query Language (SQL). The term “query” denominates a set of commands for retrieving data from a stored database. The query language is used to specify a query with parameters that determine which data is retrieved from a database.
Optimization and execution of a database query can be a resource-intensive and time-consuming process. Further, the larger the database, the longer the time needed to execute the query. In order to prevent an excessive drain on resources, many databases are configured with query optimizers. A query optimizer analyzes an SQL query and determines more efficient ways to execute the query.
Some SQL queries require scanning sequentially through a database record for matching string of data. For example, the query may scan for a piece of text or small character string in a document or database record that comprises a large string of text. These queries are typically quite inefficient in identifying the needed text from the database record. Often no other predicate values exist to eliminate records from the search, so a table scan is performed to search for the needed text. When each record in the table is scanned, each field or record in the table is searched from the beginning to the end for the text string being sought. Searching for text string in a database in this manner is inefficient.
In query optimizers in the prior art, sequentially searching for a string in a database record is done without regard to the starting position of the search. Without a way to more effectively search for a string in a database, computer systems will continue to suffer from inefficient searches and their waste of system resources.